﻿using System.Text;

namespace DeviceCommons.DeviceMessages.Models.V1
{
    public class DeviceMessageInfo : IDeviceMessageInfo
    {
        public DeviceMessageInfo()
        {
        }

        public byte Length => (byte)(DIDBytes?.Length ?? 0);

        public byte[]? DIDBytes { get => Encoding.UTF8.GetBytes(DID ?? ""); set => DID = Encoding.UTF8.GetString(value ?? []); }

        public string? DID { get; set; }

        public byte DeviceType { get; set; } = 0x00;

        public IDeviceMessageInfoReadings? Reading { get; set; }

        public int DataLength => 2 + Length + (Reading?.DataLength ?? 0);
    }
}
